package com.example.testapplication.databinding;

import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.lifecycle.ViewModelProvider;

import android.os.Bundle;

import com.example.testapplication.R;

public class DataBindingActivity extends AppCompatActivity {
    private DataBindingViewModel viewModel;
    private ActivityDataBindingBinding binding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //setContentView(R.layout.activity_data_binding);
        // 初始化
        binding = DataBindingUtil.setContentView(this,R.layout.activity_data_binding);
        viewModel = new ViewModelProvider(this).get(DataBindingViewModel.class);
        binding.setData(viewModel);
        binding.setLifecycleOwner(this);
    }
}